import Vue from "vue";
import VueRouter from "vue-router";

const Layout = () => import("../views/Layout/index.vue");

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    redirect: "/login", //设置页面重定向 ，默认打开登陆页面
    hiden: true,
    meta: {
      name: "主页",
      icon: "el-icon-s-promotion"
    }
  },
  {
    path: "/login",
    name: "Login",
    hiden: true,
    component: () => import("../views/Login/index.vue"),
    meta: {
      name: "登录",
      icon: "el-icon-s-home"
    }
  },
  {
    path: "/console",
    name: "console",
    component: Layout,
    redirect: "index",
    meta: {
      name: "控制台",
      icon: "console"
      // icon: "el-icon-s-order"
    },
    children: [
      {
        path: "/index",
        name: "index",
        component: () => import("../views/Console/index.vue"),
        meta: {
          name: "首页"
        }
      }
    ]
  },
  {
    path: "/info",
    name: "info",
    component: Layout,
    meta: {
      name: "信息管理",
      icon: "menger"
      // icon: "el-icon-s-promotion"
    },
    children: [
      {
        path: "/infoIndex",
        name: "infoIndex",
        component: () => import("../views/Info/index.vue"),
        meta: {
          name: "信息列表"
        }
      },
      {
        path: "/infoCategory",
        name: "infoCategory",
        component: () => import("../views/Info/Category.vue"),
        meta: {
          name: "信息分类"
        }
      }
    ]
  },
  {
    path: "/user",
    name: "user",
    component: Layout,
    meta: {
      name: "用户管理",
      icon: "user"
      // icon: "el-icon-s-custom"
    },
    children: [
      {
        path: "/userIndex",
        name: "userIndex",
        component: () => import("../views/User/index.vue"),
        meta: {
          name: "用户信息"
        }
      }
    ]
  }
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes
});

export default router;
